$(function(){

  if($(".fixedBtnList").length > 0){
    function scrollTopShow(){

      var timeID,fixedBtnListObj = $(".fixedBtnList");
      fixedBtnListObj.hide();
      $("body").on("touchmove", function () {
        var t;
        window.onscroll = function(){
          clearTimeout(t);
          t = setTimeout(function(){
            clearTimeout(timeID);
            timeID = setTimeout(function(){fixedBtnListObj.hide();}, 2000);
          }, 100);
        }
      });

      $("body").on("touchend", function () {
        clearTimeout(timeID);
        timeID = setTimeout(function(){fixedBtnListObj.hide();}, 2000);
      });

      $(window).scroll(function(){
        var num = $(this).scrollTop();
        if(num>100){
          clearTimeout(timeID);
          fixedBtnListObj.show();
        }else{
          fixedBtnListObj.hide();
        }
      });
    }
    scrollTopShow();

    $("a[linkStyle=aFeedBack]").click(function(){
      var param = escape(window.location.href);
      var url = $(this).attr("href") + "&from=" + param;
      $(this).attr("href",url);
    });

  }

  // iscroll
  function setScrollWidth(){
    $(".srcollId").each(function(){
      $(this).find(".srcollCon").width($(this).find(".srcollData").width());
    })
  }
  setScrollWidth();

  $(window).bind("resize",function(){
    setScrollWidth();
  })

  var iScrollArr = ["headerMenu","applicationCon_android","applicationCon_ios"],iScrollArrLength = iScrollArr.length;

  for(var iScroll_i=0;iScroll_i<iScrollArrLength;iScroll_i++){
    if($("#" + iScrollArr[iScroll_i]).length > 0){
      new IScroll('#'+iScrollArr[iScroll_i],{
        eventPassthrough: true,
        scrollX: true,
        scrollY: false,
        preventDefault: false
      });
    }
  }

  // iscroll

  // 显示更多频道
  if($(".header .headerMenuMoreBtn").length > 0){
    var headerMenuMoreObj = $(".header .headerMenuMore");
    $(".header .headerMenuMoreBtn").live("touchend",function(){
      if(headerMenuMoreObj.css("display") == "block"){
        removeBodyHidden();
        headerMenuMoreObj.css("display","none");
      }else{
        addBodyHidden();
        headerMenuMoreObj.css("display","block");
      }
    })
  }
  // 显示更多频道

  // 显示搜索框
  if($(".header .headerSearchBtn").length > 0){
    $(".header .headerSearchBtn").live("touchend",function(){
      addBodyHidden();
      $(".searchPop").css("display","block");
      $(".searchPop .searchInput").focus();
    })

    $(".searchPop .cancelInput").live("touchend",function(){
      removeBodyHidden();
      $(".searchPop").css("display","none");
      $(".searchPop .searchInput").blur();
      return false;
    })

    $(".searchPop .iDelete").live("touchend",function(){
      $(".searchPop .searchInput").val("").blur().focus();
    })

    $(".searchPop .searchInput").live("keyup",function(){
      if($(this).val() == ""){
        $(".searchPop .iDelete").css("display","none");
      }else{
        $(".searchPop .iDelete").css("display","block");
      }
    })


  }
  // 显示搜索框

  function addBodyHidden(){
    $("body").addClass("hidden");
  }

  function removeBodyHidden(){
    $("body").removeClass("hidden");
  }


})

